package by.grsu.epam.dao.entitiesdao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import by.grsu.epam.dao.GenericDAOImpl;
import by.grsu.epam.dao.entitiesdao.SubscriberDAO;
import by.grsu.epam.domain.user.impl.Subscriber;

@Repository
public class SubscriberDAOImpl extends GenericDAOImpl<Subscriber, Long> implements SubscriberDAO {

	public SubscriberDAOImpl() {
		super(Subscriber.class);
	}

	@Override
	public Subscriber findByUsername(String username) {
		Criteria cr = getSession().createCriteria(Subscriber.class);
		cr.add(Restrictions.like("username", username));
        return (Subscriber) cr.uniqueResult();
	}
}
